home *** CD-ROM | disk | FTP | other *** search
- /*//////////////////////////////////////////////////////////////////////
- Filename: tools.js
- Company Name: Computer Associates International, Inc.
- Legal Copyright: Copyright (c) Computer Associates International, Inc.
- Author: Marek Matus (marek.matus@ca.com)
- Product: Tiny Firewall
- Description: javascript code - help functions
- ///////////////////////////////////////////////////////////////////////*/
-
- function getHttpParam(strParam, strDef)
- {
- var i, xparams, params, values;
- xparams = location.href.split("?");
-
- if (xparams.length > 1 )
- {
- params = xparams[1].split("&");
-
- for ( i = 0; i < params.length; i++)
- {
- values = params[i].split("=");
-
- if ( values.length > 1 )
- {
- if ( values[0] == strParam )
- {
- return unescape(values[1]);
- }
- }
- }
- }
- return strDef;
- }
-
- function getHttpParamFromStr(strParams, strParam, strDef)
- {
- var i, params, values;
-
- if ( strParams.substring(0,1) != '?' )
- strParams = '?' + strParams;
-
- var xparams = strParams.split("?");
-
- if (xparams.length > 1 )
- {
- params = xparams[1].split("&");
-
- for ( i = 0; i < params.length; i++)
- {
- values = params[i].split("=");
-
- if ( values.length > 1 )
- {
- if ( values[0] == strParam )
- {
- return unescape(values[1]);
- }
- }
- }
- }
- return strDef;
- }
-
- function transformXML(strXMLSource, strXSLTSource)
- {
- document.write( transformXMLToStr(strXMLSource, strXSLTSource) );
- }
-
- /*
- Load xsl file. If in xls file is spec. tag <xsl:variable name="INCLUDED_FILES">file1|file2|..</xsl:variable> then
- content of files (file1, file2, ...) are appended to xsl transformation. The include process is recursive. Warning: there
- can be problem with repative path to included file, the paths are related to caller (html, js), not to xsl file!
- */
- function loadXSLFile( strXSLTSource )
- {
- var xsl = new ActiveXObject("Msxml2.DOMDocument.4.0");
- xsl.async = true; //false;
-
- if ( !xsl.load( strXSLTSource ) )
- {
- alert( 'Cannot load file: ' + strXSLTSource)
- return null;
- }
-
- var nodeRoot = xsl.documentElement;
- xsl.setProperty("SelectionNamespaces", 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform"');
-
- if ( xsl.documentElement.selectSingleNode("//xsl:variable[@name='INCLUDED_FILES']") )
- {
- var strIncFiles = xsl.documentElement.selectSingleNode("//xsl:variable[@name='INCLUDED_FILES']").nodeTypedValue;
-
- var arFiles = strIncFiles.split('|');
-
- for ( var i = 0; i < arFiles.length; i++)
- {
- var xslTools = loadXSLFile( arFiles[i] );
-
- if ( xslTools )
- {
- var nodeRootTools = xslTools.documentElement;
-
- for (var j=0; j<nodeRootTools.childNodes.length; j++)
- nodeRoot.appendChild(nodeRootTools.childNodes.item(j).cloneNode(true));
- }
- }
- }
-
- return xsl;
- }
-
- function loadXMLFromReg(strRegKey)
- {
- // create xml file
- var strParams = external.CfgRegValueString(strRegKey);
-
- var srcXML = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcXML.async = true;
- srcXML.loadXML('<?xml version="1.0" encoding="UTF-8"?><filter></filter>');
- srcRoot = srcXML.selectSingleNode("//filter");
-
- params = strParams.split("&");
-
- for ( var i = 0; i < params.length; i++)
- {
- var strPair = params[i].split("=");
-
- if ( strPair.length > 1 )
- {
- var strParamName = strPair[0];
- var strParamValue = unescape(strPair[1]);
-
- strParamValue = replace(strParamValue, '<', '<');
- strParamValue = replace(strParamValue, '>', '>');
- strParamValue = replace(strParamValue, '&', '&;');
-
- var nodeParams = srcXML.createElement(strParamName);
- nodeParams.text = strParamValue;
-
- srcRoot.appendChild(nodeParams);
- }
- }
-
- //alert(srcXML.xml)
- return srcXML.xml;
- }
-
- function transformXMLToStr(strXMLSource, strXSLTSource)
- {
- var xml = new ActiveXObject("Msxml2.DOMDocument.4.0");
- xml.async = true; //false;
-
- // Load XML
- if ( strXMLSource.substring(0,5) == '|reg_' ) // indicate thet is not file name but registry key
- xml.loadXML( loadXMLFromReg( strXMLSource.substring(5) ))
- else
- xml.load( strXMLSource );
-
- // Load the XSL
- var xsl = loadXSLFile( strXSLTSource );
-
- // Transform
- return xml.transformNode(xsl);
- }
-
- // Transforms XML file with xsl template.
- // This method also takes parameters from url and add them to xml file as follows:
- // <Document>
- // ...
- // ... content of xml ...
- // ...
- // <Params>
- // <Param name="name1>value1<Param>
- // <Param name="name2>value2<Param>
- // ...
- // </Params>
- // </Document>
- //
- // If params parameter is given, it is added to URL as additional parameters.
- /*function transformXMLWithURLParams(xmlDoc, xslPath, params)
- {
- // get URL parameters and call TransformXMLWithParams(xmlDoc, xslPath, params)
- parString = document.location.href.split("?");
- if (!params)
- params = "";
-
- if (parString.length > 1 )
- {
- return transformXMLWithParams(xmlDoc, xslPath, parString[1] + "&" + params);
- }
- else
- {
- return transformXMLWithParams(xmlDoc, xslPath, params);
- }
- }*/
-
- // This function is the same as TransformXMLWithURLParams(xmlDoc, xslPath) with one exception.
- // Parameters are not taken from url but they are only included as an input parameter of this function.
- // Syntax of param string is the same as url params, e.g. param1=value1¶m2=value2&...
- function transformXMLWithParams(xmlDoc, xslPath, params)
- {
- var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcTree.async=true; //false;
- srcTree.load(xmlDoc);
-
- if (params != null && params.length > 0)
- {
- // create Params tag as a child of Document
- var nodeRoot = srcTree.selectSingleNode("/child::*");
- var nodeParams = srcTree.createElement("Params");
- nodeRoot.appendChild(nodeParams);
-
- // parse parameters 'params' and add them to Params tag
-
- // set of parameters
- var pars = params.split("&");
- for (var i = 0; i < pars.length; i++)
- {
- var paramParts = pars[i].split("=");
-
- // create Param tag
- var paramTag = srcTree.createElement("Param");
- paramTag.setAttribute("name", unescape(paramParts[0]));
- paramTag.text = unescape(paramParts[1]);
- nodeParams.appendChild(paramTag);
- }
- }
-
- // Load the XSL
- var xsltTree = loadXSLFile( xslPath );
-
- return srcTree.transformNode(xsltTree);
- }
-
- function getParserXML( eParser, bUseClientParser)
- {
- if ( eParser == XM_SBX )
- oParser = (bUseClientParser? external.ClientParser(XM_SBX) : external.ServerParser(XM_SBX))
-
- else if ( eParser == XM_FW )
- oParser = (bUseClientParser? external.ClientParser(XM_FW) : external.ServerParser(XM_FW))
-
- else if ( eParser == XM_IDS )
- oParser = (bUseClientParser? external.ClientParser(XM_IDS) : external.ServerParser(XM_IDS))
-
- else if ( eParser == XM_APPREP )
- oParser = (bUseClientParser? external.ClientParser(XM_APPREP) : external.ServerParser(XM_APPREP))
-
- if ( !oParser )
- return '';
- else
- return oParser.Xml;
- }
-
- function transformXMLWithParamsExMerged(eParser, xslPath, params)
- {
- var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcTree.async=true; //false;
-
- srcTree.loadXML( getParserXML( eParser, false) );
- var nodeRoot = srcTree.selectSingleNode("/child::*");
-
- var strCXml = getParserXML( eParser, true);
-
- if ( strCXml)
- {
- var srcClientDB = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcClientDB.async=true; //false;
-
- srcClientDB.loadXML( strCXml );
-
- // copy rules
- var nodeRootClient = srcClientDB.documentElement.selectSingleNode('//RuleList');
-
- var oNodeRootClient = srcTree.createElement("ClientRuleList");
- nodeRoot.appendChild(oNodeRootClient);
-
- for (var j=0; j<nodeRootClient.childNodes.length; j++)
- {
- oNodeRootClient.appendChild(nodeRootClient.childNodes.item(j).cloneNode(true));
- }
-
- // copy definitions
- var nodeRootClient = srcClientDB.documentElement.selectSingleNode('//Definitions');
-
- var oNodeRootClient = srcTree.createElement("ClientDefinitions");
- nodeRoot.appendChild(oNodeRootClient);
-
- for (var j=0; j<nodeRootClient.childNodes.length; j++)
- {
- oNodeRootClient.appendChild(nodeRootClient.childNodes.item(j).cloneNode(true));
- }
- }
-
- if ( params && params != null && params.length > 0)
- {
- // create Params tag as a child of Document
- var nodeParams = srcTree.createElement("Params");
- nodeRoot.appendChild(nodeParams);
-
- // parse parameters 'params' and add them to Params tag
-
- // set of parameters
- var pars = params.split("&");
- for (var i = 0; i < pars.length; i++)
- {
- var paramParts = pars[i].split("=");
-
- // create Param tag
- var paramTag = srcTree.createElement("Param");
- paramTag.setAttribute("name", unescape(paramParts[0]));
- paramTag.text = unescape(paramParts[1]);
- nodeParams.appendChild(paramTag);
- }
- }
-
- //alert( srcTree.xml )
-
- // Load the XSL
- var xsltTree = loadXSLFile( xslPath );
-
- return srcTree.transformNode(xsltTree);
- }
-
- function transformPartXMLWithParams(eParser, strNode, bUseClientParser, xslPath, params)
- {
- var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcTree.async=true;
-
- var oParser;
-
- if ( eParser == XM_SBX )
- oParser = (bUseClientParser? external.ClientParser(XM_SBX) : external.ServerParser(XM_SBX))
-
- else if ( eParser == XM_FW )
- oParser = (bUseClientParser? external.ClientParser(XM_FW) : external.ServerParser(XM_FW))
-
- else if ( eParser == XM_IDS )
- oParser = (bUseClientParser? external.ClientParser(XM_IDS) : external.ServerParser(XM_IDS))
-
- else if ( eParser == XM_APPREP )
- oParser = (bUseClientParser? external.ClientParser(XM_APPREP) : external.ServerParser(XM_APPREP))
-
- if ( !oParser )
- return '';
-
- //alert( oParser.xmlex(strNode) );
- srcTree.loadXML(oParser.xmlex(strNode));
- //srcTree.loadXML(oParser.Xml);
-
- if (params && params != null && params.length > 0)
- {
- // create Params tag as a child of Document
- var nodeRoot = srcTree.selectSingleNode("/child::*");
- var nodeParams = srcTree.createElement("Params");
- nodeRoot.appendChild(nodeParams);
-
- // parse parameters 'params' and add them to Params tag
-
- // set of parameters
- var pars = params.split("&");
- for (var i = 0; i < pars.length; i++)
- {
- var paramParts = pars[i].split("=");
-
- // create Param tag
- var paramTag = srcTree.createElement("Param");
- paramTag.setAttribute("name", unescape(paramParts[0]));
- paramTag.text = unescape(paramParts[1]);
- nodeParams.appendChild(paramTag);
- }
- }
-
- // Load the XSL
- var xsltTree = loadXSLFile( xslPath );
-
- return srcTree.transformNode(xsltTree);
- }
-
- function transformXMLWithParamsEx(eParser, bUseClientParser, xslPath, params)
- {
- var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcTree.async=true;
-
- var oParser;
-
- if ( eParser == XM_SBX )
- oParser = (bUseClientParser? external.ClientParser(XM_SBX) : external.ServerParser(XM_SBX))
-
- else if ( eParser == XM_FW )
- oParser = (bUseClientParser? external.ClientParser(XM_FW) : external.ServerParser(XM_FW))
-
- else if ( eParser == XM_IDS )
- oParser = (bUseClientParser? external.ClientParser(XM_IDS) : external.ServerParser(XM_IDS))
-
- else if ( eParser == XM_APPREP )
- oParser = (bUseClientParser? external.ClientParser(XM_APPREP) : external.ServerParser(XM_APPREP))
-
- if ( !oParser )
- return '';
-
- srcTree.loadXML(oParser.Xml);
-
- if (params && params != null && params.length > 0)
- {
- // create Params tag as a child of Document
- var nodeRoot = srcTree.selectSingleNode("/child::*");
- var nodeParams = srcTree.createElement("Params");
- nodeRoot.appendChild(nodeParams);
-
- // parse parameters 'params' and add them to Params tag
-
- // set of parameters
- var pars = params.split("&");
- for (var i = 0; i < pars.length; i++)
- {
- var paramParts = pars[i].split("=");
-
- // create Param tag
- var paramTag = srcTree.createElement("Param");
- paramTag.setAttribute("name", unescape(paramParts[0]));
- paramTag.text = unescape(paramParts[1]);
- nodeParams.appendChild(paramTag);
- }
- }
-
- // Load the XSL
- var xsltTree = loadXSLFile( xslPath );
-
- return srcTree.transformNode(xsltTree);
- }
-
- // transformXMLWithXMLParams - similar to transformXMLWithParams, however,
- // params are a valid xml node structure =>
- // strXmlParams = '<doc><Params><Param name="filter">filter</Param></Params><Strings><String name="STR_X">...</doc>'
- function transformXMLWithXMLParams(xmlDoc, xslPath, strXmlParams)
- {
- var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0");
- srcTree.async=true; //false;
- srcTree.load(xmlDoc);
-
- var nodeRoot = srcTree.documentElement;
-
- // append the Params xml into the original xml file
- var paramsTree = new ActiveXObject("Msxml2.DOMDocument.4.0");
- paramsTree.async=true; //false;
- paramsTree.resolveExternals = false;
- paramsTree.loadXML( strXmlParams );
-
- if ( paramsTree )
- {
- var nodeRootParams = paramsTree.documentElement;
-
- for (var j=0; j < nodeRootParams.childNodes.length; j++)
- nodeRoot.appendChild(nodeRootParams.childNodes.item(j).cloneNode(true));
- }
-
- // Load the XSL
- var xsltTree = loadXSLFile( xslPath );
-
- return srcTree.transformNode(xsltTree);
- }
-
- // Returns 1 if value:
- // 1. is <> 0
- // 2. is true
- // 3. if parseInt() <> 0
- function parseBoolean( value )
- {
- if ( typeof( value) == "string" )
- {
- if ( value.toLowerCase() == "true")
- return 1;
- else if ( value.toLowerCase() == "false" )
- return 0;
- else if ( isNaN(parseInt(value)))
- return 0;
- else
- return parseInt(value) == 0? 0 : 1;
- }
- else if ( typeof( value ) == "number" )
- return value == 0? 0: 1;
- else if ( typeof( value ) == "boolean")
- return value? 1: 0;
-
- return 0;
- }
-
- // Return true if value is valid integer.
- function isInt( value )
- {
- return !isNaN ( parseInt( value ))
- }
-
- // Parse port value, return empty string if port is invalid.
- function parsePort( value )
- {
- if ( isInt( value ))
- {
- var iValue = parseInt( value );
-
- if ( iValue >= 0 )
- return iValue + "";
- }
-
- return "";
- }
-
- // Parse port range values, return empty string if port range is invalid.
- function parsePortRange( valueFrom, valueTo )
- {
- if ( isInt( valueFrom ) && isInt( valueTo ) )
- {
- var iValueFrom = parseInt( valueFrom );
- var iValueTo = parseInt( valueTo );
-
- if ( iValueFrom >= 0 && iValueFrom <= iValueTo )
- return iValueFrom + "-" + iValueTo;
- }
-
- return "";
- }
- // Add option to <select> - through document.write!
- function addOption(strValue, strText, bSelected, strColor)
- {
- document.write('<option ' + (strColor? 'style="color: ' + strColor + ';"' : '') + ' VALUE="' + strValue + '"' + ( bSelected? ' selected' : '' ) + '>' + strText + '</option>' );
- }
-
- function addOptionToStr(strValue, strText, bSelected, strColor)
- {
- return '<option ' + (strColor? 'style="color: ' + strColor + ';"' : '') + ' VALUE="' + strValue + '"' + ( bSelected? ' selected' : '' ) + '>' + strText + '</option>';
- }
-
- // Remove all options from <select>
- function clearOptionsDOM( objSelect )
- {
- var len = objSelect.length;
-
- for (var i=0; i < len; i++)
- objSelect.remove( 0 );
-
- }
-
- function unescapeHTMLSpec(strValue)
- {
- var sValue = strValue;
-
- sValue = replace( sValue, '<','<');
- sValue = replace( sValue, '>','>');
- sValue = replace( sValue, '&','&');
-
- return sValue;
- }
-
- // Add option to <select>
- function addOptionDOM(objSelect, strValue, strText, strColor, bSelected)
- {
- // new Option replaces "<" -> "<" etc. but from xml they already are replaced!
- var oOpt = new Option( unescapeHTMLSpec(strText), unescapeHTMLSpec(strValue) );
-
- if ( strColor )
- oOpt.style.color = strColor;
-
- if ( bSelected )
- oOpt.selected = true;
-
- objSelect.add( oOpt );
- }
-
- function entitiesToStr( strValue )
- {
- return replace( strValue, '»', String.fromCharCode(187) );
- }
-
- // Pre-select option in <select>
- function selectOption(objSelect, strValue)
- {
- for (var i=0; i < objSelect.length; i++)
- {
- if ( objSelect.options[i].value == strValue )
- objSelect.options[i].selected = true;
- }
- }
-
- function replace(string,text,by) {
- // Replaces text with by in string
- var strLength = string.length, txtLength = text.length;
- if ((strLength == 0) || (txtLength == 0)) return string;
-
- var i = string.indexOf(text);
- if ((!i) && (text != string.substring(0,txtLength))) return string;
- if (i == -1) return string;
-
- var newstr = string.substring(0,i) + by;
-
- if (i+txtLength < strLength)
- newstr += replace(string.substring(i+txtLength,strLength),text,by);
-
- return newstr;
- }
-
- function Trim(sValue)
- {
- if(sValue.length < 1)
- return "";
-
- sValue = RTrim(sValue);
- sValue = LTrim(sValue);
-
- return sValue;
- }
-
- function RTrim( sValue )
- {
- var strTemp = "";
-
- if( sValue.length < 0)
- return "";
-
- var iTemp = sValue.length -1;
-
- while(iTemp > -1)
- {
- if(sValue.charAt(iTemp) != ' ')
- {
- strTemp = sValue.substring(0,iTemp +1);
- break;
- }
- iTemp = iTemp-1;
-
- } //End While
-
- return strTemp;
- } //End Function
-
- function LTrim(sValue)
- {
- if(sValue.length < 1)
- return"";
-
- var strTemp = "";
- var iTemp = 0;
-
- while(iTemp < sValue.length)
- {
- if(sValue.charAt(iTemp) != ' ')
- {
- strTemp = sValue.substring(iTemp,sValue.length);
- break;
- }
- iTemp = iTemp + 1;
- } //End While
- return strTemp;
- } //End Function
-
- function stringToHTMLValue( strValue )
- {
- var str = replace( strValue, '"','"');
-
- return str;
-
- }
- function stringToHTML( strValue )
- {
- var str = replace( strValue, '\\','\\\\');
- str = replace( str, '\'','\\\'');
- str = replace( str, '"','"');
-
- return str;
- }
-
- function replaceXMLEntities( strValue )
- {
- var str = replace( strValue, '<','<');
- str = replace( str, '>','>');
- str = replace( str, '"','"');
- str = replace( str, '&','&');
-
- return str;
- }
-
- function processMsg(strText, strParam1, strParam2)
- {
- var strRet = replace( strText, '{0}', strParam1);
- strRet = replace( strRet, '{1}', strParam2);
-
- return strRet;
- }
-
- /* Get interface language */
- function getLanguage()
- {
- var strLang = external.CfgRegValueString("Language").toLowerCase();
- // NOW CAN BE ONLY 'enu' or 'cze'!!!
- if ( strLang != 'enu' && strLang != 'cze')
- strLang = 'enu';
-
- return strLang;
- }
-
- /* Insert into file correct language string table */
- /* If getLanguage returns some language code then (other then enu) strPath will be modified:
- requested js file will be redirected into subfolder <lang>, e.g. ../strings/arn-strings.js and
- language is 'cze' then path will be modified to ../strings/cze/arn-strings.js. */
- /*function insertLanguageStrings(strPath)
- {
- var strLang = getLanguage().toLowerCase();
- var strStringTableFile = strPath;
-
- var strFolder = "";
- var strFileName = "";
- var i = strPath.lastIndexOf('/');
-
- if ( i == -1)
- strFileName = strPath; // it is only file name
- else
- {
- strFolder = strPath.substring(0,i);
- strFileName = strPath.substring(i+1);
- }
-
- // if lang is specified
- if (strLang && strLang != 'enu')
- {
- document.write('<script language = "jscript" src="' + strFolder + '/' + strLang + '/strings.js"></script>')
- if ( strFileName != 'strings.js')
- document.write('<script language = "jscript" src="' + strFolder + '/' + strLang + '/' + strFileName + '"></script>')
- }
- else
- {
- document.write('<script language = "jscript" src="' + strFolder + '/strings.js"></script>')
- if ( strFileName != 'strings.js')
- document.write('<script language = "jscript" src="' + strFolder + '/' + strFileName + '"></script>')
- }
- }*/
-
- function insertLanguageStrings(strPath, strLangParam)
- {
- // In some cases is not possible to call getLanguage() (due to cannot call external) e.g. in
- // page showed through window.showModalDialog and then we need parameter strLangParam.
- var strLang = strLangParam;
- if ( !strLangParam )
- strLang = getLanguage().toLowerCase();
-
- var strStringTableFile = strPath;
-
- var strFolder = "";
- var strFileName = "";
- var i = strPath.lastIndexOf('/');
-
- if ( i == -1)
- strFileName = strPath; // it is only file name
- else
- {
- strFolder = strPath.substring(0,i);
- strFileName = strPath.substring(i+1,strPath.length-3);
- }
-
- var defST, pageST;
- // if lang is specified
- if (strLang && strLang != 'enu')
- {
- defST = strFolder + '/strings_' + strLang + '.js';
- pageST = strFolder + '/' + strFileName + '_' + strLang + '.js';
- }
- else
- {
- defST = strFolder + '/strings.js';
- pageST = strFolder + '/' + strFileName + '.js';
- }
-
- document.write('<script language = "jscript" src="' + defST + '"></script>')
- if ( strFileName != 'strings')
- document.write('<script language = "jscript" src="' + pageST + '"></script>')
- }
-
- /* Insert correct JS file with menu */
- /* strPath must ended .js, we need path because we do not know in which folder menu js file is located */
- function insertMenu(strPath)
- {
- // not used now
- /* var strFile = strPath;
-
- if (isVPNFirewall())
- strFile = strPath.substring(0,strPath.length-3) + '_vpn' + '.js';
-
- document.write('<script language = "jscript" src="' + strFile + '"></script>')*/
- }
-
- //////////////////////////////////////////////////////////////////////
- ///////// GET LDAP GROUPS AND USERS //////////////////////////////////
- //////////////////////////////////////////////////////////////////////
- function getLDAPGroups()
- {
- try
- {
- var obj = new ActiveXObject('UmxUTA.UmxUTA');
- var arrayVariants= new VBArray(obj.GetUsers(1));
- return arrayVariants.toArray();
- }
- catch (e)
- {
- return new Array();
- }
- }
-
- function getLDAPUsers()
- {
- try
- {
- var obj = new ActiveXObject('UmxUTA.UmxUTA');
- var arrayVariants= new VBArray(obj.GetUsers(0));
- return arrayVariants.toArray();
- }
- catch (e)
- {
- return new Array();
- }
- }
-
- function isLDAPName( strName )
- {
- var i = strName.indexOf('User:');
- if ( i >= 0 )
- return true;
-
- var i = strName.indexOf('RUser:');
- if ( i >= 0 )
- return true;
-
- var i = strName.indexOf('Group:');
- if ( i >= 0 )
- return true;
-
- var i = strName.indexOf('RGroup:');
- if ( i >= 0 )
- return true;
-
- return false;
- }
-
- function isVPNLDAPName( strName )
- {
- return ( strName.substring(0,1) == 'R');
- }
-
- function getVPNLDAPName( strName )
- {
- if ( isVPNLDAPName(strName))
- return strName;
- else
- return 'R' + strName;
- }
-
- function getLANLDAPName( strName )
- {
- if ( isVPNLDAPName(strName))
- return strName.substring(1);
- else
- return strName;
- }
-
- //Remove RUser:, RGroup:, User:, Group: substring and domain name
- function prepareLDAPName( strName )
- {
- var i = strName.indexOf('@');
- if ( i )
- {
- strName = strName.substring(0,i);
- strName = replace( strName, 'RUser:', '');
- strName = replace( strName, 'RGroup:', '');
- strName = replace( strName, 'User:', '');
- strName = replace( strName, 'Group:', '');
- }
-
- return strName;
- }
-
- function getLDAPOptions( bVPN )
- {
- var strHTML = '';
-
- strHTML += '<option value="" style="color: ' + COLOR_DB_ROW + '">' + getStr('fw','STR_VPN_N_SEL_LDAP_GROUP') + '</option>';
- var arUsers= getLDAPGroups();
- for (var i= 0;i< arUsers.length; i++)
- strHTML += '<option value="' + (bVPN? 'R' : '') + 'Group:' + arUsers[i] + '">' + prepareLDAPName(arUsers[i]) + '</option>';
-
- strHTML += '<option value="" style="color: ' + COLOR_DB_ROW + '">' + getStr('fw','STR_VPN_N_SEL_LDAP_USER') + '</option>';
- var arUsers= getLDAPUsers();
- for (var i= 0;i< arUsers.length; i++)
- strHTML += '<option value="' + (bVPN? 'R' : '') + 'User:' + arUsers[i] + '">' + prepareLDAPName(arUsers[i]) + '</option>';
-
- return strHTML;
- }
-
- //////////////////////////////////////////////////////////////////////
- ///////// FUNCTIONS FOR WORKING WITH CHECKBOXES //////////////////////
- //////////////////////////////////////////////////////////////////////
-
-
- // Check all checkboxes in given form with given prefix
- function checkAll(form, sPrefix)
- {
- for (var index = 0; index < form.elements.length; index++)
- {
- var sName = form.elements[index].name;
-
- if(sName.substring(0, sPrefix.length) == sPrefix)
- {
- if( !form.elements[index].checked )
- form.elements[index].checked = true;
- }
- }
- }
-
- // Uncheck all checkboxes in given form with given prefix
- function uncheckAll(form, sPrefix)
- {
- for (var index = 0; index < form.elements.length; index++)
- {
- var sName = form.elements[index].name;
- if(sName.substring(0, sPrefix.length) == sPrefix)
- {
- if( form.elements[index].checked )
- form.elements[index].checked = false;
- }
- }
- }
-
- // Return true if any checkbox is checked
- function isAnyChecked(form, sPrefix)
- {
- for (var index = 0; index < form.elements.length; index++)
- {
- var sName = form.elements[index].name;
- if(sName.substring(0, sPrefix.length) == sPrefix)
- {
- if( form.elements[index].checked )
- return true;
- }
- }
- return false;
- }
-
- // Show modal dialog for direct daytime setting
- function getTimeDirect(strInitValue)
- {
- var sFeatures="dialogHeight: 340px; dialogWidth: 350px; help:no; status:no; resizable:no; center:yes;";
-
- var arParams = new Array();
- arParams[0] = strInitValue;
- arParams[1] = getLanguage();
- arParams[2] = external;
-
- return window.showModalDialog( '../common/daytime-direct.html', arParams, sFeatures );
- }
-
- function TIME_ShowEditDlg(strObjID, strIntervals)
- {
- external.CfgRegValueString("daytime-edit.html_params") = "?objid=" + escape(strObjID) + "&intervals=" + escape(strIntervals)
-
- var arParams = new Array();
- arParams[0] = external;
-
- var sFeatures="dialogHeight: 340px; dialogWidth: 415px; help:no; status:no; resizable:no; center:yes;";
-
- var arRetVal = window.showModalDialog( '../common/daytime-edit.html', arParams, sFeatures );
-
- if ( arRetVal && arRetVal[0] && arRetVal[1])
- return arRetVal[1];
-
- return '';
- }
-
- function formatTimeDirect( strDaytime )
- {
- var strFormated = strDaytime;
- if (strFormated)
- {
- strFormated = replace(strFormated,"|","<br>");
- strFormated = replace(strFormated,"#"," ");
- }
-
- return strFormated;
- }
-
- function formatUsers( strUsers )
- {
- var strFormated = strUsers;
- if ( strFormated )
- strFormated = replace( strFormated, "|", "<br>");
-
- return strFormated;
- }
-
- function getSystemAccount( strAccount )
- {
- if ( strAccount == "system")
- return RA_SYSTEM;
- else if ( strAccount == "both")
- return RA_BOTH;
- else
- return RA_USER;
- }
-
- function isSystemAppRepGroup( strName )
- {
- // 'FileMod' 'FileReadMod'
- // AllowHiddenFilesApps + AllowReadOnlyFilesApps
- if ( isPersonalVersion() )
- return (( strName == 'AllowHiddenFilesApps') || ( strName == 'AllowReadOnlyFilesApps'));
- else
- return false;
- }
-
- function isInArray( arList, obj)
- {
- if ( !arList )
- return false;
-
- for ( var i = 0; i < arList.length; i++)
- {
- if ( arList[i] == obj )
- return true;
- }
-
- return false;
- }
-
- function isNumber( strNumber )
- {
- if ( !strNumber.toString() )
- return false;
-
- var oRe = new RegExp("^[0-9]*$") ;
-
- return oRe.test(Trim(strNumber));
- }
-